﻿using Autofac;
using Microsoft.Extensions.Configuration;

namespace CoreCms.Net.Utility
{

    public static class Storage
    {
        /// <summary>
        /// 静态构造函数
        /// </summary>
        static Storage()
        {
            //var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
            //    .AddJsonFile("appsettings.json", true, true);
            //Configuration = builder.Build();

            //Assemblys = DependencyContext.Default.CompileLibraries
            //    .Where(x => x.Type == "project")
            //    .Select(x => AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName(x.Name)))
            //    .ToList();
        }



        /// <summary>
        /// 配置文件的根节点
        /// </summary>
        public static IConfigurationRoot Configuration { get; }

        /// <summary>
        /// 全局程序集
        /// </summary>
        //public static List<Assembly> Assemblys { get; }


        /// <summary>
        /// Autofac依赖注入静态服务
        /// </summary>
        public static ILifetimeScope Container;

        /// <summary>
        /// 获取服务(Single)
        /// </summary>
        /// <typeparam name="T">接口类型</typeparam>
        /// <returns></returns>
        public static T GetService<T>() where T : class
        {
            return Container.Resolve<T>();
        }


    }

}